package com.multi.web.controller.tenant;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.multi.tenant.resp.BkTenantSignupInfoResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.multi.common.annotation.Log;
import com.multi.common.core.controller.BaseController;
import com.multi.common.core.domain.AjaxResult;
import com.multi.common.enums.BusinessType;
import com.multi.tenant.domain.BkTenantSignupInfo;
import com.multi.tenant.service.IBkTenantSignupInfoService;
import com.multi.common.utils.poi.ExcelUtil;
import com.multi.common.core.page.TableDataInfo;

/**
 * 租户签约Controller
 *
 * @author ruoyi
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/tenant/signup")
public class BkTenantSignupInfoController extends BaseController
{
    @Autowired
    private IBkTenantSignupInfoService bkTenantSigupInfoService;

    /**
     * 查询租户签约列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BkTenantSignupInfo bkTenantSigupInfo)
    {
        startPage();
        List<BkTenantSignupInfoResp> list = bkTenantSigupInfoService.selectBkTenantSignupInfoList(bkTenantSigupInfo);
        return getDataTable(list);
    }

    /**
     * 导出租户签约列表
     */
    @Log(title = "租户签约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BkTenantSignupInfo bkTenantSigupInfo)
    {
        List<BkTenantSignupInfoResp> list = bkTenantSigupInfoService.selectBkTenantSignupInfoList(bkTenantSigupInfo);
        ExcelUtil<BkTenantSignupInfoResp> util = new ExcelUtil<BkTenantSignupInfoResp>(BkTenantSignupInfoResp.class);
        util.exportExcel(response, list, "租户签约数据");
    }

    /**
     * 获取租户签约详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bkTenantSigupInfoService.selectBkTenantSignupInfoById(id));
    }

    /**
     * 新增租户签约
     */
    @Log(title = "租户签约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BkTenantSignupInfo bkTenantSigupInfo)
    {
        return toAjax(bkTenantSigupInfoService.insertBkTenantSignupInfo(bkTenantSigupInfo));
    }

    /**
     * 修改租户签约
     */
    @Log(title = "租户签约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BkTenantSignupInfo bkTenantSigupInfo)
    {
        return toAjax(bkTenantSigupInfoService.updateBkTenantSignupInfo(bkTenantSigupInfo));
    }

    /**
     * 删除租户签约
     */

    @Log(title = "租户签约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bkTenantSigupInfoService.deleteBkTenantSignupInfoByIds(ids));
    }
}
